<?php

class Logging {
	
	public static function errLogArray($description, $array, $delimiter = ' | ') {
		$message = $description.': ';
		$first = true;
		foreach ($array as $key => $value) {
			if($first) {
				$message .= $key.'='.$value;
				$first = false;
			} else {
				$message .= $delimiter.$key.'='.$value;
			}
		}
		user_error($message);
	}
	
	public static function errLogString($description, $string) {
		$message = $description.': '.$string;
		user_error($message);
	}
	
	public static function errLogExecute($description) {
		user_error($description);
	}
	
	public static function fileLogString($string, $description = null, $pathToRoot = '../') {
		$file = fopen($pathToRoot."log/log", "a");
		$message = '['.date("Y-m-d G:i:s").'] ';
		if($description != null) {
			$message .= $description.': ';
		}
		$message .= $string.'\n';
		fwrite($file, $message);
		fclose($file);
	}
}

?>